unit OdontoDB;

interface

uses
  System.SysUtils, System.Classes, Vcl.Controls, Vcl.StdCtrls, Vcl.Mask,
  Vcl.DBCtrls, Vcl.Graphics, Vcl.Themes;

type
  TDBOdontoEdit = class(TDBEdit)
  private
     FCorFoco: TColor;
     procedure setCorFoco(Value: TColor);
     procedure doMudarCorComFoco(Sender: TObject);
     procedure doMudarCorSemFoco(Sender: TObject);
  protected
  public
     constructor Create(AOwner: TComponent); override;
  published
     property CorFoco: TColor read FCorFoco write FCorFoco;
  end;

  TDBLookupOdontoEdit = class(TDBLookupComboBox)
  private
     FCorFoco: TColor;
     procedure setCorFoco(Value: TColor);
     procedure doMudarCorComFoco(Sender: TObject);
     procedure doMudarCorSemFoco(Sender: TObject);
  protected
  public
     constructor Create(AOwner: TComponent); override;
  published
     property CorFoco: TColor read FCorFoco write FCorFoco;
  end;

  TDBOdontoCheckBox = class(TDBCheckBox)
  private
  protected
  public
     constructor Create(AOwner: TComponent); override;
  published
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Odonto DB', [TDBOdontoEdit]);
  RegisterComponents('Odonto DB', [TDBLookupOdontoEdit]);
  RegisterComponents('Odonto DB', [TDBOdontoCheckBox]);
end;

{ TDBOdontoEdit }

constructor TDBOdontoEdit.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   CharCase := ecUpperCase;
   OnEnter := doMudarCorComFoco;
   OnExit := doMudarCorSemFoco;
   CorFoco := $00EBEBEB;
end;

procedure TDBOdontoEdit.doMudarCorComFoco(Sender: TObject);
begin
   TDBOdontoEdit(Self).Color := FCorFoco
end;

procedure TDBOdontoEdit.doMudarCorSemFoco(Sender: TObject);
begin
   TDBOdontoEdit(Self).Color := clWindow;
end;

procedure TDBOdontoEdit.setCorFoco(Value: TColor);
begin
   if ( Value <> clWindow ) then
      FCorFoco := Value;
end;

{ TDBLookupOdontoEdit }

constructor TDBLookupOdontoEdit.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   OnEnter := doMudarCorComFoco;
   OnExit := doMudarCorSemFoco;
   CorFoco := $00EBEBEB;
end;

procedure TDBLookupOdontoEdit.doMudarCorComFoco(Sender: TObject);
begin
   TDBOdontoEdit(Self).Color := FCorFoco
end;

procedure TDBLookupOdontoEdit.doMudarCorSemFoco(Sender: TObject);
begin
   TDBOdontoEdit(Self).Color := clWindow;
end;

procedure TDBLookupOdontoEdit.setCorFoco(Value: TColor);
begin
   if ( Value <> clWindow ) then
      FCorFoco := Value;
end;

{ TDBOdontoCheckBox }

constructor TDBOdontoCheckBox.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  ValueChecked := 'S';
  ValueUnchecked := 'N';
end;

end.
